package org.qiuqiu.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.qiuqiu.dao.UserDao;
import org.qiuqiu.pojo.User;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author 杜秋野
 *
 */
public class OtherAction extends ActionSupport implements ServletResponseAware,	ServletRequestAware {
	
	HttpServletRequest request;
	HttpServletResponse response;
	private String inputCode;
	private String keyword;
	
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}
	
	public String getInputCode() {
		return inputCode;
	}
	public void setInputCode(String inputCode) {
		this.inputCode = inputCode;
	}
	public String getKeyword() {
		return keyword;
	}
	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
	
	/**验证码检验
	 * @throws IOException
	 */
	public void checkCode() throws IOException{
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		HttpSession session = request.getSession();
        String code = (String)session.getAttribute("code");
        if(inputCode.equals(code)){
        	out.print("true");
        }else{
        	out.print("false");
        }
	}
}
